package com.huawei.appmarket.service.videostream.view;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import com.huawei.appgallery.foundation.ui.framework.activity.BaseActivity;
import com.huawei.appgallery.horizontalcard.api.view.BounceHorizontalRecyclerView;
import com.huawei.appgallery.horizontalcard.api.view.BounceHorizontalRecyclerView.c;
import com.huawei.appmarket.framework.widget.CustomActionBar;
import com.huawei.appmarket.service.store.awk.bean.VideoStreamListCardBean;
import com.huawei.appmarket.service.videostream.view.VideoStreamActivityProtocol.Request;
import com.huawei.appmarket.service.videostream.viewmodel.VideoStreamViewModel;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import o.ckt;
import o.dgm;
import o.djt;
import o.doo;
import o.ContentManager;
import o.dvq;
import o.emp;
import o.emr;
import o.emt;
import o.CollectCheck;
import o.ActivityUtil;
import o.evd;
import o.evk;
import o.VideoNetChangeDialog;
import o.VideoNetChangeDialog.d;
import o.ewm.e;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;
import o.kz;

public class VideoStreamActivity extends BaseActivity<VideoStreamActivityProtocol> {
    private BounceHorizontalRecyclerView ʻॱ;
    private LinearLayout ˊॱ;
    private emr ˋॱ;
    private CustomActionBar ˏॱ;
    private ViewPagerLayoutManager ͺ;
    private VideoStreamViewModel ॱˊ;
    private int ॱˋ;
    private final BroadcastReceiver ॱˎ = new SafeBroadcastReceiver(this) {
        final /* synthetic */ VideoStreamActivity ˋ;

        {
            this.ˋ = r1;
        }

        public void onReceiveMsg(Context context, Intent intent) {
            if ("android.net.conn.CONNECTIVITY_CHANGE".equals(intent.getAction())) {
                if (emt.ॱ()) {
                    this.ˋ.ʻॱ.ˋ().ˊ();
                    int ˊ = doo.ˊ(((ConnectivityManager) this.ˋ.getSystemService("connectivity")).getActiveNetworkInfo());
                    if (ˊ != this.ˋ.ॱˋ) {
                        this.ˋ.ॱˋ = ˊ;
                        if (doo.ˊ(context)) {
                            this.ˋ.ॱˊ.ʻ();
                        }
                    }
                }
            } else if (dvq.ˊ().equals(intent.getAction())) {
                this.ˋ.ʻॱ.ˋ().ˊ();
            }
        }
    };
    private boolean ᐝॱ = true;

    private static void ˊ(Activity activity) {
        activity.requestWindowFeature(1);
        Window window = activity.getWindow();
        evd.ˏ(window);
        window.setNavigationBarColor(-16777216);
        evd.ˊ(window, 1);
        window.setStatusBarColor(-16777216);
        window.getDecorView().setBackgroundColor(-16777216);
    }

    public void onCreate(@Nullable Bundle bundle) {
        super.onCreate(bundle);
        ˊ((Activity) this);
        if (ʾ() == null || ((VideoStreamActivityProtocol) ʾ()).ॱ() == null) {
            finish();
            return;
        }
        Request ॱ = ((VideoStreamActivityProtocol) ʾ()).ॱ();
        final String ˏ = ॱ.ˏ();
        final long ˋ = ॱ.ˋ();
        int ˊ = ॱ.ˊ();
        final String ˎ = ॱ.ˎ();
        final int ˎ2 = dgm.ˎ(this);
        final int ॱ2 = ॱ.ॱ();
        if (CollectCheck.isEmpty((List) emp.ˎ().ˊ.get(Long.valueOf(ˋ)))) {
            finish();
            return;
        }
        List arrayList = new ArrayList((Collection) emp.ˎ().ˊ.get(Long.valueOf(ˋ)));
        emp.ˎ().ˊ.remove(Long.valueOf(ˋ));
        if (CollectCheck.isEmpty(arrayList)) {
            finish();
            return;
        }
        this.ॱˊ = new VideoStreamViewModel();
        setContentView(h.ʻ);
        this.ˏॱ = (CustomActionBar) findViewById(j.ˊˈ);
        this.ˊॱ = (LinearLayout) findViewById(j.ʻﹳ);
        this.ʻॱ = (BounceHorizontalRecyclerView) findViewById(j.ʾʾ);
        this.ˋॱ = new emr(arrayList);
        this.ˋॱ.ˋ(true);
        this.ʻॱ.setItemAnimator(null);
        this.ʻॱ.setAdapter(this.ˋॱ);
        this.ͺ = new ViewPagerLayoutManager(this, 0);
        if (ˊ < arrayList.size() && ˊ >= 0) {
            this.ͺ.ॱ(ˊ, 0);
        }
        this.ॱˊ.ॱ(ˋ);
        this.ॱˊ.ˎ(ॱ.ॱॱ());
        this.ʻॱ.setLayoutManager(this.ͺ);
        this.ͺ.ˋ(this.ॱˊ);
        ac_().ॱ(this.ॱˊ);
        this.ʻॱ.setStartLoadNum(3);
        this.ʻॱ.setOnLoadListener(new c(this) {
            final /* synthetic */ VideoStreamActivity ʻ;

            public boolean ˏ() {
                if (!this.ʻ.ᐝॱ) {
                    return false;
                }
                this.ʻ.ॱˊ.ˊ(ˏ, ˎ, ˋ, ˎ2, ॱ2);
                return true;
            }
        });
        ˏ(arrayList);
        this.ॱˊ.ॱॱ().ॱ(this, new kz<Boolean>(this) {
            final /* synthetic */ VideoStreamActivity ॱ;

            {
                this.ॱ = r1;
            }

            public /* synthetic */ void ॱ(@Nullable Object obj) {
                ˊ((Boolean) obj);
            }

            public void ˊ(@Nullable Boolean bool) {
                if (bool != null && bool.booleanValue()) {
                    this.ॱ.finish();
                }
            }
        });
        ͺ();
        ᐝ();
        ॱˊ();
        IntentFilter intentFilter = new IntentFilter(dvq.ˊ());
        intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
        ActivityUtil.registerReceiver(this, intentFilter, this.ॱˎ);
    }

    private void ˏ(List<VideoStreamListCardBean> list) {
        this.ॱˊ.ʽ().ॱ(Boolean.valueOf(true));
        this.ॱˊ.ʽ().ॱ(this, new kz<Boolean>(this) {
            final /* synthetic */ VideoStreamActivity ॱ;

            {
                this.ॱ = r1;
            }

            public /* synthetic */ void ॱ(@Nullable Object obj) {
                ˏ((Boolean) obj);
            }

            public void ˏ(@Nullable Boolean bool) {
                if (bool != null) {
                    this.ॱ.ᐝॱ = bool.booleanValue();
                }
            }
        });
        this.ॱˊ.ˊ().ॱ(this, new kz<List<VideoStreamListCardBean>>(this) {
            final /* synthetic */ VideoStreamActivity ˏ;

            {
                this.ˏ = r1;
            }

            public void ॱ(@Nullable List<VideoStreamListCardBean> list) {
                this.ˏ.ˋॱ.ˋ(list);
            }
        });
        this.ॱˊ.ˊ().ॱ(list);
        this.ॱˊ.ˎ().ॱ(this, new kz<Boolean>(this) {
            final /* synthetic */ VideoStreamActivity ˎ;

            {
                this.ˎ = r1;
            }

            public /* synthetic */ void ॱ(@Nullable Object obj) {
                ˏ((Boolean) obj);
            }

            public void ˏ(@Nullable Boolean bool) {
                if (bool != null) {
                    this.ˎ.ʻॱ.setLoading(bool.booleanValue());
                }
            }
        });
        this.ॱˊ.ˋ().ॱ(this, new kz<Integer>(this) {
            final /* synthetic */ VideoStreamActivity ˏ;

            {
                this.ˏ = r1;
            }

            public /* synthetic */ void ॱ(@Nullable Object obj) {
                ˏ((Integer) obj);
            }

            public void ˏ(@Nullable Integer num) {
                this.ˏ.ˋ(num);
            }
        });
        this.ॱˊ.ᐝ().ॱ(this, new kz<Boolean>(this) {
            final /* synthetic */ VideoStreamActivity ˋ;

            {
                this.ˋ = r1;
            }

            public /* synthetic */ void ॱ(@Nullable Object obj) {
                ˎ((Boolean) obj);
            }

            public void ˎ(@Nullable Boolean bool) {
                if (bool != null && bool.booleanValue()) {
                    if (doo.ˊ(this.ˋ)) {
                        evk.ॱ(this.ˋ.getString(n.ـʻ), 0).ˋ();
                    } else {
                        evk.ॱ(this.ˋ.getString(n.ʹˊ), 0).ˋ();
                    }
                }
            }
        });
    }

    private void ˋ(final Integer num) {
        if (doo.ˊ(this)) {
            new Handler().postDelayed(new Runnable(this) {
                final /* synthetic */ VideoStreamActivity ॱ;

                public void run() {
                    if (num != null) {
                        this.ॱ.ͺ.ॱ(num.intValue() + 1, 0);
                    }
                }
            }, 2500);
        }
    }

    private void ᐝ() {
        this.ˏॱ.setShareIconVisible(8);
        this.ˏॱ.setSearchIconVisible(8);
        this.ˏॱ.setCloseIconRes(e.ᐝᐝ);
        this.ˏॱ.setActionbarClickListener(new djt(this) {
            final /* synthetic */ VideoStreamActivity ˏ;

            {
                this.ˏ = r1;
            }

            public void ᐝॱ() {
                this.ˏ.finish();
            }

            public void ʼॱ() {
            }

            public void ˊˋ() {
            }
        });
    }

    private void ͺ() {
        if (emt.ॱ()) {
            this.ˊॱ.setVisibility(8);
            return;
        }
        this.ˊॱ.setOnClickListener(new ckt(new OnClickListener(this) {
            final /* synthetic */ VideoStreamActivity ˎ;

            {
                this.ˎ = r1;
            }

            public void onClick(View view) {
                this.ˎ.ˊॱ.setVisibility(8);
                emt.ˏ(true);
                this.ˎ.ॱˊ.ˏ(this.ˎ.ͺ.ᐝ(0));
            }
        }));
        this.ˊॱ.setVisibility(0);
        ᐝॱ();
    }

    private void ॱˊ() {
        this.ॱˋ = doo.ˊ(((ConnectivityManager) ContentManager.getInstant().getContext().getSystemService("connectivity")).getActiveNetworkInfo());
    }

    private void ᐝॱ() {
        if (VideoNetChangeDialog.ˊ() && VideoNetChangeDialog.ˏ(this)) {
            VideoNetChangeDialog o_evs = new VideoNetChangeDialog(this);
            o_evs.ˋ(new d(this) {
                final /* synthetic */ VideoStreamActivity ˏ;

                {
                    this.ˏ = r1;
                }

                public void ˊ() {
                }

                public void ॱ() {
                    this.ˏ.ॱˊ.ॱॱ().ॱ(Boolean.valueOf(true));
                }
            });
            o_evs.ˋ();
        }
    }

    public void onDestroy() {
        ActivityUtil.unregisterReceiver(this, this.ॱˎ);
        super.onDestroy();
    }

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        this.ʻॱ.ˋ().ˊ();
    }

    public void onBackPressed() {
        super.onBackPressed();
        emt.ˏ(true);
    }
}
